<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box">
        <div class="box">1</div>
        <div class="box">2</div>
        <div class="box">3</div>
    </div>
</body>
<script>
    var box = document.getElementsByClassName('box');
    /*
      1.let块级作用域
      2.let不存在变量的提前声明
      3.let 不能重复声明
      4.let 虽然是块级作用域但是不影响作用域链
    */
    for (let i = 0; i < box.length; i++) {
        box[i].onclick = function() {
            alert(i);
        }
    }

    {
        let girl = '班长';
        console.log(girl);
    }
    // console.log(girl);
    // console.log(girl);
    //var girl='班长';

    console.log(yuzong);
    let yuzong = 'binishuai';
    //let yuzong='meiwoshuai';
    {
        let girl = '班长';

        function fn() {
            console.log(girl);
        }
        fn();
    }
</script>

</html>